// import userEvent from "@testing-library/user-event"
import { Table, TableProps } from "antd"
import dayjs from "dayjs"
import React from "react"
import {User} from "screens/project-list/search-panel"

interface Project {
    id: string;
    name: string;
    personId: string;
    pin: boolean;
    organization: string;
    created: number;
}

interface ListProps extends TableProps<Project>{
    users: User[]
}
//localeCompare 可以排序中文字符
export const List = ({users, ...props}: ListProps) => {
    return <Table pagination={false} columns={[{
        title: "名称",
        dataIndex: "name",
        sorter: (a, b) => a.name.localeCompare(b.name)
    },{
        title: "部门",
        dataIndex: "organization"
    },{
        title: "负责人",
        render(value, project) {
            return <span>
                {users.find(user => user.id === project.personId)?.name || "未知"}
            </span>
        }
    }, {
        title: "创建时间",
        render(value, project) {
            return <span>
                {project.created ? dayjs(project.created).format("YYYY-MM-DD") : "无"}
            </span>
        }
    }]} {...props}>

    </Table>
}